package com.MyApp.CompanyRank;

import info.bliki.wiki.model.WikiModel;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.LineNumberReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/*
 import org.wikipedia.miner.model.*;
 import org.wikipedia.miner.util.PageIterator;
 import org.wikipedia.miner.util.WikipediaConfiguration;
 import org.wikipedia.miner.comparison.ArticleComparer;
 import org.wikipedia.miner.comparison.ArticleComparison;
 import org.wikipedia.miner.db.WEnvironment.StatisticName;
 */
import au.com.bytecode.opencsv.CSVReader;

public class DBpediaTable {
    HashMap<String, String[]> nameMap = new HashMap<String, String[]>();

    HashMap<String, String> nameInstruct = new HashMap<String, String>(); // added by ider

    HashMap<String, String> nameInstruct_cn = new HashMap<String, String>(); // added by ider
    HashMap<String, String> name_cn = new HashMap<String, String>(); // added by ider
    HashMap<String, String> nameDate = new HashMap<String, String>(); // added by ider

    HashMap<String, String[]> childrenMap = new HashMap<String, String[]>();
    // WikiDB wikiDB;

    String[] row0;
    String[] row1;

    public final static int billion = 1000000000;
    public final static int million = 1000000;

    public static String dataDir = "rankingdata" + File.separator;
    public static String countryListFilename = dataDir + "countrylist.csv";
    public static String currencyRateFilename = dataDir + "currencyrate.csv";

    public static HashMap<String, String> countryName2CurrencyName = getCountryName2CurrencyName();
    public static HashMap<String, Double> currencyRateTable = getCurrencyRateTable();

    // public DBpediaTable(WikiDB wikidb, Reader reader) throws IOException {
    public DBpediaTable(Reader reader) throws IOException {
        CSVReader csvReader = new CSVReader(reader);
        List<String[]> nlist = csvReader.readAll();
        csvReader.close();
        // wikiDB = wikidb;

        row0 = nlist.get(0);
        row1 = nlist.get(1);
        for (int i = 2; i < nlist.size(); i++) {
            String[] row = nlist.get(i);
            String a = // DBpediaTable.getArticleTitle(wikiDB, row[1], row[0]);
            DBpediaTable.getArticleTitle(row[1], row[0]);
            if (a != null) {
                nameMap.put(a, row);
            }
        }
        getInstructANDdate();
    }

    /**
     * to get nameInstructANDdate by ider
     * 
     * @throws IOException
     */
    public void getInstructANDdate() throws IOException {
        String homeDir = "rankingdata" + File.separator;

        String filename = homeDir + File.separator + "GlobalList_en_zh.csv";
        CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(filename), "UTF-8"));
        List<String[]> list = csvReader.readAll();
        csvReader.close();
        for (int i = 0; i < list.size(); i++) {
            String[] row = list.get(i);
            nameInstruct.put(row[0].replace("_", " "), row[4]);
            nameInstruct_cn.put(row[0].replace("_", " "), row[5]);
            name_cn.put(row[0].replace("_", " "), row[1]);
            nameDate.put(row[0].replace("_", " "), row[3]);
        }

        // String filename_Instruct =
        // homeDir+File.separator+"GlobalList_Instruct.csv";
        // CSVReader csvReader = new CSVReader(new InputStreamReader(new
        // FileInputStream(filename_Instruct), "UTF-8"));
        // List <String[]> Instruct_list = csvReader.readAll();
        // csvReader.close();
        // for (int i = 0; i<Instruct_list.size(); i++) {
        // String[] row = Instruct_list.get(i);
        // nameInstruct.put(row[0].replace("_"," "), row[1]);
        // }
        // String filename_Date = homeDir+File.separator+"GlobalList_Date.csv";
        // csvReader = new CSVReader(new InputStreamReader(new
        // FileInputStream(filename_Date), "UTF-8"));
        // List <String[]> Date_list = csvReader.readAll();
        // csvReader.close();
        //
        // String regex = "[0-9]{4}";
        // for (int i = 0; i<Date_list.size(); i++) {
        // String[] row = Date_list.get(i);
        // System.out.println(row[1]);
        // Pattern pat = Pattern.compile(regex);
        // Matcher matcher = pat.matcher(row[1]);
        // String year =null;
        // while(matcher.find()){
        // year = matcher.group();
        // }
        // nameDate.put(row[0].replace("_"," "), year);
        // }

    }

    public static HashMap<String, String> getCountryName2CurrencyName() {
        HashMap<String, String> map = new HashMap<String, String>();
        String line = null;
        try {

            LineNumberReader csvReader = new LineNumberReader(new InputStreamReader(new FileInputStream(new File(
                    countryListFilename)), "UTF-8"));
            String[] row;

            // build the <schoolName, almaMater Sum Count> map and also find the
            // max almamater sum count
            while ((line = csvReader.readLine()) != null) {
                row = line.split(",");
                map.put(row[0], row[2]);
            }
            csvReader.close();

        } catch (IOException ioe) {
            System.out.println("IOException : " + ioe);
        }
        return map;
    }

    public static HashMap<String, Double> getCurrencyRateTable() {
        HashMap<String, Double> map = new HashMap<String, Double>();
        String line = null;
        try {
            LineNumberReader csvReader = new LineNumberReader(new InputStreamReader(new FileInputStream(new File(
                    currencyRateFilename)), "UTF-8"));
            String[] row;

            while ((line = csvReader.readLine()) != null) {
                row = line.split(",");
                Double r = Double.valueOf(row[3]);
                map.put(row[0], r);
            }
            csvReader.close();
        } catch (IOException ioe) {
            System.out.println("IOException : " + ioe + " " + line);
        }
        return map;
    }

    public int size() {
        return nameMap.size();
    }

    public static String[] parseCSV(String str) {
        try {
            java.io.StringReader sr = new java.io.StringReader(str);
            CSVReader csvReader = new CSVReader(sr);
            String[] row = csvReader.readNext();
            csvReader.close();
            sr.close();
            return row;
        } catch (IOException ioe) {
            return null;
        }
    }

    String[] getRow(String nameString) {
        return nameMap.get(nameString);
    }

    public String getValue(String nameString, String propertyName) {
        String[] row = getRow(nameString);
        return getValue(row, propertyName);
    }

    public String getRawValue(String nameString, String propertyName) {
        String[] row = getRow(nameString);
        String rawValue = getRawValue(row, propertyName);
        if (rawValue != null)
            return rawValue.trim();
        return null;
    }

    public String[] getRawValues(String nameString, String propertyName) {
        String[] row = getRow(nameString);
        String rawValue = getRawValue(row, propertyName).trim();
        return splitWikiString(rawValue);
    }

    static public String[] splitWikiString(String str) {
        if (str == null)
            return null;
        String rawValue = str.trim();
        if (rawValue.startsWith("{") && rawValue.endsWith("}")) {
            rawValue = rawValue.substring(1, (rawValue.length() - 1));
            if (rawValue.contains("|")) {
                return rawValue.split("\\|");
            }
        }
        String[] ret = { rawValue };
        return ret;
    }

    public String getValue(String[] row, String propertyName) {
        String ret = getRawValue(row, propertyName);
        if (ret == null)
            return null;
        int li = ret.lastIndexOf('/');
        if (li >= 0) {
            ret = ret.substring(li + 1);
            ret = ret.replace('_', ' ').trim();
        }
        return ret;
    }

    public String[] getValues(String nameString, String propertyName) {
        String ret[] = getRawValues(nameString, propertyName);
        if (ret == null)
            return null;

        for (int i = 0; i < ret.length; i++) {
            int li = ret[i].lastIndexOf('/');

            if (li >= 0) {
                ret[i] = ret[i].substring(li + 1);
                ret[i] = ret[i].replace('_', ' ').trim();
            }
        }
        return ret;
    }

    public String getHTMLValue(String nameString, String propertyName) {
        String ret = getRawValue(nameString, propertyName);
        if (ret == null || ret.equals("NULL"))
            return null;
        WikiModel wikiModel = new WikiModel("http://en.wikipedia.org/wiki/${image}",
                "http://en.wikipedia.org/wiki/${title}");
        return wikiModel.render(ret);
    }

    public String getRawValue(String[] row, String propertyName) {
        if (row == null)
            return null;
        for (int i = 0; i < row0.length; i++) {
            if (row0[i].equals(propertyName)) {
                if (row.length <= i)
                    return null;
                if (row[i] == null || row[i].equals("NULL"))
                    return null;
                return row[i];
            }
        }
        return null;
    }

    public String getAddress(String nameString) {
        String ret = "";
        String tableAddress = getValue(nameString, "address");
        if (tableAddress != null)
            ret += tableAddress;
        String city = getRawValue(nameString, "city_label");
        if (city != null && !city.equals("NULL")) {
            if (ret.length() == 0)
                ret += city;
            else
                ret += ", " + city;
        }
        String postalCode = getValue(nameString, "postalCode");
        if (postalCode != null && !postalCode.equals("NULL"))
            ret += " " + postalCode;
        String country = getValue(nameString, "country");
        if (country != null && !country.equals("NULL"))
            ret += " " + country;
        if (ret.length() == 0)
            return null;
        return ret;
    }

    public String[] getGeoPoint(String nameString) {
        // a hack, hard code the places where the geo coding is missing
        if (nameString.equals("McGill University")) {
            String[] gr = { "45.504167", "-73.574722" };
            return gr;
        }
        if (nameString.equals("University of Wisconsin–Madison")) {
            String[] gr = { "43.075", "-89.417222" };
            return gr;
        }
        if (nameString.equals("Lawrence University")) {
            String[] gr = { "44.2600708", "-88.3964233" };
            return gr;
        }
        if (nameString.equals("University of Maryland, College Park")) {
            String[] gr = { "38.9861183", "-76.9401093" };
            return gr;
        }
        if (nameString.equals("University of Washington")) {
            String[] gr = { "47.6567612", "-122.312027" };
            return gr;
        }
        if (nameString.equals("City College of New York")) {
            String[] gr = { "40.8187493", "-73.9506061" };
            return gr;
        }
        if (nameString.equals("Juilliard School")) {
            String[] gr = { "40.7732697", "-73.9827576" };
            return gr;
        }
        if (nameString.equals("Beloit College")) {
            String[] gr = { "42.5030403", "-89.02948" };
            return gr;
        }
        if (nameString.equals("Lake Forest College")) {
            String[] gr = { "42.2509003", "-87.8307419" };
            return gr;
        }
        if (nameString.equals("University of St Andrews")) {
            String[] gr = { "56.3407898", "-2.80845" };
            return gr;
        }
        if (nameString.equals("University of Greenwich")) {
            String[] gr = { "51.4904709", "0.06475" };
            return gr;
        }
        if (nameString.equals("National Autonomous University of Mexico")) {
            String[] gr = { "19.3288898", "-99.1872253" };
            return gr;
        }
        if (nameString.equals("Saint Petersburg State University")) {
            String[] gr = { "59.9416618", "30.3009872" };
            return gr;
        }
        if (nameString.equals("Utrecht University")) {
            String[] gr = { "52.0858002", "5.1308398" };
            return gr;
        }
        if (nameString.equals("Radboud University Nijmegen")) {
            String[] gr = { "51.8230553", "5.8625002" };
            return gr;
        }
        if (nameString.equals("Wabash College")) {
            String[] gr = { "40.0394096", "-86.9043884" };
            return gr;
        }
        if (nameString.equals("University of Rostock")) {
            String[] gr = { "54.0844435", "12.1127325" };
            return gr;
        }
        if (nameString.equals("St. Olaf College")) {
            String[] gr = { "44.4604111", "-93.1802368" };
            return gr;
        }
        if (nameString.equals("Heriot-Watt University")) {
            String[] gr = { "55.6069984", "-2.78392" };
            return gr;
        }
        if (nameString.equals("Hobart and William Smith Colleges")) {
            String[] gr = { "42.8596497", "-76.9853287" };
            return gr;
        }
        if (nameString.equals("Lviv University")) {
            String[] gr = { "49.8443985", "24.0254002" };
            return gr;
        }
        if (nameString.equals("Grinnell College")) {
            String[] gr = { "41.7462196", "-92.7225418" };
            return gr;
        }
        if (nameString.equals("Ben-Gurion University of the Negev")) {
            String[] gr = { "31.2630405", "34.8022156" };
            return gr;
        }
        if (nameString.equals("Occidental College")) {
            String[] gr = { "34.1269798", "-118.2145233" };
            return gr;
        }
        if (nameString.equals("Kenyon College")) {
            String[] gr = { "40.3763885", "-82.4019318" };
            return gr;
        }
        if (nameString.equals("Bates College")) {
            String[] gr = { "44.1050301", "-70.2055817" };
            return gr;
        }
        if (nameString.equals("Macquarie University")) {
            String[] gr = { "-33.7736397", "151.1119537" };
            return gr;
        }
        if (nameString.equals("College of the Holy Cross")) {
            String[] gr = { "42.2396202", "-71.8126831" };
            return gr;
        }
        if (nameString.equals("Bryn Mawr College")) {
            String[] gr = { "40.0247688", "-75.3188324" };
            return gr;
        }
        if (nameString.equals("University of Exeter")) {
            String[] gr = { "50.7344589", "-3.5355599" };
            return gr;
        }
        if (nameString.equals("Ohio University")) {
            String[] gr = { "39.3246498", "-82.0963821" };
            return gr;
        }
        if (nameString.equals("Indiana University Bloomington")) {
            String[] gr = { "39.1716499", "-86.5156326" };
            return gr;
        }
        if (nameString.equals("United Nations University")) {
            String[] gr = { "35.6623726", "139.7083588" };
            return gr;
        }
        if (nameString.equals("Northeastern University")) {
            String[] gr = { "42.3402405", "-71.0889587" };
            return gr;
        }
        if (nameString.equals("College of Saint Benedict and Saint John's University")) {
            String[] gr = { "45.5844917", "-94.3939285" };
            return gr;
        }
        if (nameString.equals("Goldsmiths, University of London")) {
            String[] gr = { "51.4739", "-0.0374" };
            return gr;
        }
        if (nameString.equals("University of Bordeaux")) {
            String[] gr = { "44.8003998", "-0.59598" };
            return gr;
        }
        if (nameString.equals("University of Calcutta")) {
            String[] gr = { "22.5747299", "88.3630066" };
            return gr;
        }
        if (nameString.equals("Dublin Institute of Technology")) {
            String[] gr = { "53.3373833", "-6.2684522" };
            return gr;
        }
        if (nameString.equals("University of Maine")) {
            String[] gr = { "44.89785", "-68.6701126" };
            return gr;
        }
        if (nameString.equals("Eureka College")) {
            String[] gr = { "40.7138901", "-89.269165" };
            return gr;
        }
        if (nameString.equals("City Law School")) {
            String[] gr = { "51.5272217", "-0.105556" };
            return gr;
        }
        if (nameString.equals("Pennsylvania Academy of the Fine Arts")) {
            String[] gr = { "39.9556694", "-75.1629105" };
            return gr;
        }
        if (nameString.equals("Hamilton College (New York)")) {
            String[] gr = { "43.0501213", "-75.4019623" };
            return gr;
        }
        if (nameString.equals("Antioch College")) {
            String[] gr = { "39.7999306", "-83.8899078" };
            return gr;
        }
        if (nameString.equals("Colorado College")) {
            String[] gr = { "38.8465996", "-104.8242874" };
            return gr;
        }
        if (nameString.equals("Royal Military Academy Sandhurst")) {
            String[] gr = { "51.340532", "-0.7687" };
            return gr;
        }
        if (nameString.equals("London Academy of Music and Dramatic Art")) {
            String[] gr = { "51.490556", "-0.214444" };
            return gr;
        }
        if (nameString.equals("Georgia Southwestern State University")) {
            String[] gr = { "32.0578003", "-84.2193832" };
            return gr;
        }
        if (nameString.equals("University of Dhaka")) {
            String[] gr = { "23.731547", "90.392497" };
            return gr;
        }
        if (nameString.equals("Forman Christian College")) {
            String[] gr = { "31.5228996", "74.3351974" };
            return gr;
        }
        if (nameString.equals("Scripps College")) {
            String[] gr = { "51.3518791", "-0.25383" };
            return gr;
        }
        if (nameString.equals("Washington College")) {
            String[] gr = { "39.217222", "-76.068056" };
            return gr;
        }
        if (nameString.equals("Visva-Bharati University")) {
            String[] gr = { "23.6657877", "87.6822155" };
            return gr;
        }
        if (nameString.equals("American Academy of Dramatic Arts")) {
            String[] gr = { "40.7454551", "-73.9848183" };
            return gr;
        }
        if (nameString.equals("Salesian College (London)")) {
            String[] gr = { "51.3518791", "-0.25383" };
            return gr;
        }
        if (nameString.equals("University of Colorado Denver")) {
            String[] gr = { "39.7458801", "-105.0025177" };
            return gr;
        }
        if (nameString.equals("Sweet Briar College")) {
            String[] gr = { "37.5538902", "-79.0800018" };
            return gr;
        }
        if (nameString.equals("Sun Yat-sen University")) {
            String[] gr = { "23.090035754540416", "113.30221652984619" };
            return gr;
        }

        if (nameString.equals("St Ignatius' College")) {
            String[] gr = { "51.672939", "-0.055751" };
            return gr;
        }

        /**
         * edited by ider
         */
        if (nameString.equals("Aix-Marseille University")) {
            String[] gr = { "43.293611", "5.357778" };
            return gr;
        }
        if (nameString.equals("Allen University")) {
            String[] gr = { "34.010556", "-81.020556" };
            return gr;
        }
        if (nameString.equals("Beijing Film Academy")) {
            String[] gr = { "39.971667", "116.355081" };
            return gr;
        }
        if (nameString.equals("Berry College")) {
            String[] gr = { "34.3075", "-85.213611" };
            return gr;
        }
        if (nameString.equals("Capital Normal University")) {
            String[] gr = { "39.930336", "116.307664" };
            return gr;
        }
        if (nameString.equals("Carthage College")) {
            String[] gr = { "42.623487", "-87.819948" };
            return gr;
        }
        if (nameString.equals("Catholic University of Korea")) {
            String[] gr = { "37.5859", "127.00433" };
            return gr;
        }
        if (nameString.equals("Central Academy of Drama")) {
            String[] gr = { "39.935992", "116.404481" };
            return gr;
        }
        if (nameString.equals("Chang Gung University")) {
            String[] gr = { "25.035225", "121.389539" };
            return gr;
        }
        if (nameString.equals("Chengdu University of Technology")) {
            String[] gr = { "30.676206", "104.145394" };
            return gr;
        }
        if (nameString.equals("China Europe International Business School")) {
            String[] gr = { "31.237247", "121.596933" };
            return gr;
        }
        if (nameString.equals("China Foreign Affairs University")) {
            String[] gr = { "39.926511", "116.344575" };
            return gr;
        }
        if (nameString.equals("China Jiliang University")) {
            String[] gr = { "30.318922", "120.364094" };
            return gr;
        }
        if (nameString.equals("China Pharmaceutical University")) {
            String[] gr = { "32.074594", "118.774178" };
            return gr;
        }
        if (nameString.equals("China University of Geosciences")) {
            String[] gr = { "39.990972", "116.350761" };
            return gr;
        }
        if (nameString.equals("China University of Mining and Technology")) {
            String[] gr = { "39.996742", "116.349603" };
            return gr;
        }
        if (nameString.equals("China University of Petroleum")) {
            String[] gr = { "40.219467", "116.247117" };
            return gr;
        }
        if (nameString.equals("China University of Political Science and Law")) {
            String[] gr = { "39.965789", "116.351728" };
            return gr;
        }
        if (nameString.equals("Chongqing University")) {
            String[] gr = { "29.560253", "106.454214" };
            return gr;
        }
        if (nameString.equals("Colorado Mesa University")) {
            String[] gr = { "39.08061", "-108.55456" };
            return gr;
        }
        if (nameString.equals("Command and Staff College")) {
            String[] gr = { "30.2218", "67.06" };
            return gr;
        }
        if (nameString.equals("Concordia College (Moorhead, Minnesota)")) {
            String[] gr = { "46.865278", "-96.77" };
            return gr;
        }
        if (nameString.equals("Coventry University")) {
            String[] gr = { "52.406654", "-1.501672" };
            return gr;
        }
        if (nameString.equals("Dakota Wesleyan University")) {
            String[] gr = { "43.698611", "-98.030833" };
            return gr;
        }
        if (nameString.equals("Dalian Maritime University")) {
            String[] gr = { "38.867733", "121.525506" };
            return gr;
        }
        if (nameString.equals("Dalian University of Technology")) {
            String[] gr = { "38.874867", "121.531681" };
            return gr;
        }
        if (nameString.equals("Dillard University")) {
            String[] gr = { "29.995", "-90.065278" };
            return gr;
        }
        if (nameString.equals("Donghua University")) {
            String[] gr = { "31.056833", "121.215656" };
            return gr;
        }
        if (nameString.equals("East China University of Science and Technology")) {
            String[] gr = { "31.143056", "121.425" };
            return gr;
        }
        if (nameString.equals("Fourth Military Medical University")) {
            String[] gr = { "34.277353", "108.979147" };
            return gr;
        }
        if (nameString.equals("Graz University of Technology")) {
            String[] gr = { "47.069381", "15.450464" };
            return gr;
        }
        if (nameString.equals("Guilford College")) {
            String[] gr = { "36.096364", "79.890756" };
            return gr;
        }
        if (nameString.equals("Hebei University of Technology")) {
            String[] gr = { "39.2401", "117.064628" };
            return gr;
        }
        if (nameString.equals("Heilongjiang University")) {
            String[] gr = { "45.707194", "126.623958" };
            return gr;
        }
        if (nameString.equals("Hunan University")) {
            String[] gr = { "28.199928", "112.930428" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology (BHU) Varanasi")) {
            String[] gr = { "25.262356", "82.989358" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology Gandhinagar")) {
            String[] gr = { "23.106858", "72.594911" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology Indore")) {
            String[] gr = { "22.587044", "75.780569" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology Patna")) {
            String[] gr = { "25.6286", "85.103039" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology Roorkee")) {
            String[] gr = { "29.862814", "77.897583" };
            return gr;
        }
        if (nameString.equals("Inner Mongolia University")) {
            String[] gr = { "40.813139", "111.689547" };
            return gr;
        }
        if (nameString.equals("Jiangnan University")) {
            String[] gr = { "31.482508", "120.277614" };
            return gr;
        }
        if (nameString.equals("Jiangsu University")) {
            String[] gr = { "32.193914", "119.519303" };
            return gr;
        }
        if (nameString.equals("Jilin University")) {
            String[] gr = { "43.824336", "125.289819" };
            return gr;
        }
        if (nameString.equals("Jinan University")) {
            String[] gr = { "23.128", "113.3477" };
            return gr;
        }
        if (nameString.equals("Riyadh Saudi Arabia")) {
            String[] gr = { "24.722", "46.627" };
            return gr;
        }
        if (nameString.equals("Kunming University of Science and Technology")) {
            String[] gr = { "25.060647", "102.695631" };
            return gr;
        }
        if (nameString.equals("Kyung Hee University")) {
            String[] gr = { "37.59675", "127.051889" };
            return gr;
        }
        if (nameString.equals("Lyon College")) {
            String[] gr = { "35.77764", "-91.62579" };
            return gr;
        }
        if (nameString.equals("Macau University of Science and Technology")) {
            String[] gr = { "22.1534", "113.5677" };
            return gr;
        }
        if (nameString.equals("McDaniel College")) {
            String[] gr = { "39.584722", "-77.001944" };
            return gr;
        }
        if (nameString.equals("Nanchang University")) {
            String[] gr = { "28.665225", "115.812417" };
            return gr;
        }
        if (nameString.equals("Nanjing Medical University")) {
            String[] gr = { "32.043847", "118.774764" };
            return gr;
        }
        if (nameString.equals("Nanjing University of Posts and Telecommunications")) {
            String[] gr = { "32.0805", "118.765" };
            return gr;
        }
        if (nameString.equals("Nantong University")) {
            String[] gr = { "31.972403", "120.910175" };
            return gr;
        }
        if (nameString.equals("National Chi Nan University")) {
            String[] gr = { "23.953", "120.9347" };
            return gr;
        }
        if (nameString.equals("National Chung Hsing University")) {
            String[] gr = { "24.122342", "120.674264" };
            return gr;
        }
        if (nameString.equals("National Taipei University")) {
            String[] gr = { "24.9463", "121.3729" };
            return gr;
        }
        if (nameString.equals("National United University")) {
            String[] gr = { "24.538389", "120.789583" };
            return gr;
        }
        if (nameString.equals("National University of Defense Technology")) {
            String[] gr = { "28.23415", "113.012022" };
            return gr;
        }
        if (nameString.equals("National University of Tainan")) {
            String[] gr = { "22.983889", "120.207222" };
            return gr;
        }
        if (nameString.equals("New College of Florida")) {
            String[] gr = { "27.385728", "82.559847" };
            return gr;
        }
        if (nameString.equals("Northeast Agricultural University")) {
            String[] gr = { "45.739969", "126.725614" };
            return gr;
        }
        if (nameString.equals("Northeast Forestry University")) {
            String[] gr = { "45.724", "126.6403" };
            return gr;
        }
        if (nameString.equals("Northwest University (China)")) {
            String[] gr = { "34.248783", "108.926569" };
            return gr;
        }
        if (nameString.equals("Novosibirsk Russia")) {
            String[] gr = { "54.988", "82.904" };
            return gr;
        }
        if (nameString.equals("Novosibirsk State University")) {
            String[] gr = { "54.843611", "83.093611" };
            return gr;
        }
        if (nameString.equals("Ouachita Baptist University")) {
            String[] gr = { "34.125", "-92.051944" };
            return gr;
        }
        if (nameString.equals("Pakistan Military Academy")) {
            String[] gr = { "34.189033", "73.263267" };
            return gr;
        }
        if (nameString.equals("Paris Dauphine University")) {
            String[] gr = { "48.870028", "2.27345" };
            return gr;
        }
        if (nameString.equals("Principia College")) {
            String[] gr = { "38.949", "-90.349" };
            return gr;
        }
        if (nameString.equals("Qingdao University")) {
            String[] gr = { "36.071944", "120.418228" };
            return gr;
        }
        if (nameString.equals("Queen Mary, University of London")) {
            String[] gr = { "51.523056", "-0.040278" };
            return gr;
        }
        if (nameString.equals("Qufu Normal University")) {
            String[] gr = { "35.595597", "116.969117" };
            return gr;
        }
        if (nameString.equals("Roanoke College")) {
            String[] gr = { "37.295833", "-80.055556" };
            return gr;
        }
        if (nameString.equals("Royal Holloway, University of London")) {
            String[] gr = { "51.424722", "-0.566944" };
            return gr;
        }
        if (nameString.equals("Second Military Medical University")) {
            String[] gr = { "31.305531", "121.545722" };
            return gr;
        }
        if (nameString.equals("Shaanxi Normal University")) {
            String[] gr = { "34.203086", "108.950236" };
            return gr;
        }
        if (nameString.equals("Shandong Normal University")) {
            String[] gr = { "36.652703", "117.042083" };
            return gr;
        }
        if (nameString.equals("Shandong University of Science and Technology")) {
            String[] gr = { "36.000103", "120.124894" };
            return gr;
        }
        if (nameString.equals("Shanghai Normal University")) {
            String[] gr = { "31.161475", "121.416531" };
            return gr;
        }
        if (nameString.equals("Shanghai University of Finance and Economics")) {
            String[] gr = { "31.304897", "121.499853" };
            return gr;
        }
        if (nameString.equals("Shanghai University of Technology")) {
            String[] gr = { "31.212569", "121.460369" };
            return gr;
        }
        if (nameString.equals("Shanxi University")) {
            String[] gr = { "37.800786", "112.586789" };
            return gr;
        }
        if (nameString.equals("Soochow University (Suzhou)")) {
            String[] gr = { "31.310833", "120.635556" };
            return gr;
        }
        if (nameString.equals("South China Normal University")) {
            String[] gr = { "23.1365", "113.3496" };
            return gr;
        }
        if (nameString.equals("South China University of Technology")) {
            String[] gr = { "23.1513", "113.3446" };
            return gr;
        }
        if (nameString.equals("Southwestern University of Finance and Economics")) {
            String[] gr = { "30.664854", "104.017126" };
            return gr;
        }
        if (nameString.equals("St. Norbert College")) {
            String[] gr = { "44.4453", "-88.0685" };
            return gr;
        }
        if (nameString.equals("Taiyuan University of Technology")) {
            String[] gr = { "37.859964", "112.522915" };
            return gr;
        }
        if (nameString.equals("The College of Saints John Fisher & Thomas More")) {
            String[] gr = { "32.701267", "97.333" };
            return gr;
        }
        if (nameString.equals("Tianjin Medical University")) {
            String[] gr = { "39.105489", "117.184617" };
            return gr;
        }
        if (nameString.equals("Tokyo University of Science")) {
            String[] gr = { "35.699389", "139.741389" };
            return gr;
        }
        if (nameString.equals("Tongji University")) {
            String[] gr = { "31.2827", "121.5066" };
            return gr;
        }
        if (nameString.equals("Universidade Estadual Paulista Júlio de Mesquita Filho")) {
            String[] gr = { "-22.8172", "-47.0694" };
            return gr;
        }
        if (nameString.equals("Université du Québec")) {
            String[] gr = { "46.119786", "73.469708" };
            return gr;
        }
        if (nameString.equals("University of Brighton")) {
            String[] gr = { "50.859086", "0.086689" };
            return gr;
        }
        if (nameString.equals("University of California, Davis")) {
            String[] gr = { "38.54", "-121.75" };
            return gr;
        }
        if (nameString.equals("University of California, Irvine")) {
            String[] gr = { "33.64535", "-117.842642" };
            return gr;
        }
        if (nameString.equals("University of Chester")) {
            String[] gr = { "53.200326", "-2.898073" };
            return gr;
        }
        if (nameString.equals("University of Eastern Finland")) {
            String[] gr = { "62.8925", "27.6783" };
            return gr;
        }
        if (nameString.equals("University of Electronic Science and Technology of China")) {
            String[] gr = { "30.675103", "104.100361" };
            return gr;
        }
        if (nameString.equals("University of Granada")) {
            String[] gr = { "37.186528", "3.599906" };
            return gr;
        }
        if (nameString.equals("University of Harderwijk")) {
            String[] gr = { "52.349444", "5.616389" };
            return gr;
        }
        if (nameString.equals("University of Hawaii at Manoa")) {
            String[] gr = { "21.297", "-157.817" };
            return gr;
        }
        if (nameString.equals("University of International Business and Economics")) {
            String[] gr = { "39.977517", "116.429592" };
            return gr;
        }
        if (nameString.equals("University of International Relations")) {
            String[] gr = { "40.003131", "116.285806" };
            return gr;
        }
        if (nameString.equals("University of Murcia")) {
            String[] gr = { "38.018258", "1.169431" };
            return gr;
        }
        if (nameString.equals("University of Nice Sophia Antipolis")) {
            String[] gr = { "43.716806", "7.267675" };
            return gr;
        }
        if (nameString.equals("University of Northampton")) {
            String[] gr = { "52.2722", "0.883192" };
            return gr;
        }
        if (nameString.equals("University of Palermo")) {
            String[] gr = { "38.1177", "13.3701" };
            return gr;
        }
        if (nameString.equals("University of Science and Technology Beijing")) {
            String[] gr = { "39.990278", "116.357222" };
            return gr;
        }
        if (nameString.equals("University of Science and Technology of China")) {
            String[] gr = { "31.8224", "117.280628" };
            return gr;
        }
        if (nameString.equals("University of Strathclyde")) {
            String[] gr = { "55.861717", "-4.2417" };
            return gr;
        }
        if (nameString.equals("University of Szeged")) {
            String[] gr = { "46.25", "20.1465" };
            return gr;
        }
        if (nameString.equals("University of Texas Health Science Center at Houston")) {
            String[] gr = { "29.703251", "-95.402871" };
            return gr;
        }
        if (nameString.equals("University of Texas MD Anderson Cancer Center")) {
            String[] gr = { "29.707999", "-95.397525" };
            return gr;
        }
        if (nameString.equals("University of the Chinese Academy of Sciences")) {
            String[] gr = { "39.908086", "116.2507  " };
            return gr;
        }
        if (nameString.equals("University of Zaragoza")) {
            String[] gr = { "41.6416", "-0.8994" };
            return gr;
        }
        if (nameString.equals("VU University Amsterdam")) {
            String[] gr = { "52.333889", "4.865" };
            return gr;
        }
        if (nameString.equals("Wesleyan College")) {
            String[] gr = { "32.874586", "-83.712469" };
            return gr;
        }
        if (nameString.equals("Western Washington University")) {
            String[] gr = { "48.734", "-122.486" };
            return gr;
        }
        if (nameString.equals("Wuhan University of Technology")) {
            String[] gr = { "30.598656", "114.342483" };
            return gr;
        }
        if (nameString.equals("Xi'an Jiaotong University")) {
            String[] gr = { "34.247222", "108.979167" };
            return gr;
        }
        if (nameString.equals("Xidian University")) {
            String[] gr = { "34.121606", "108.840431" };
            return gr;
        }
        if (nameString.equals("Xinjiang University")) {
            String[] gr = { "43.771023", "87.619409" };
            return gr;
        }
        if (nameString.equals("Xuzhou Medical College")) {
            String[] gr = { "34.264097", "117.255606" };
            return gr;
        }
        if (nameString.equals("Yangzhou University")) {
            String[] gr = { "32.379817", "119.4187" };
            return gr;
        }
        if (nameString.equals("Yantai University")) {
            String[] gr = { "37.458703", "121.468778" };
            return gr;
        }
        if (nameString.equals("Yunnan University")) {
            String[] gr = { "25.06064", "102.709377" };
            return gr;
        }
        if (nameString.equals("Zhejiang University of Technology")) {
            String[] gr = { "30.292261", "120.166392" };
            return gr;
        }
        if (nameString.equals("Zhengzhou University")) {
            String[] gr = { "34.816042", "113.535378" };
            return gr;
        }
        if (nameString.equals("California State University, Northridge")) {
            String[] gr = { "34.241667", "-118.528333" };
            return gr;
        }
        if (nameString.equals("Georgetown College")) {
            String[] gr = { "38.207", "-84.554" };
            return gr;
        }
        if (nameString.equals("King Saud University")) {
            String[] gr = { "24.722", "46.627" };
            return gr;
        }
        if (nameString.equals("Mayo Medical School")) {
            String[] gr = { "44.022136", "92.466667" };
            return gr;
        }
        if (nameString.equals("National Research University – Higher School of Economics")) {
            String[] gr = { "55.761325", "37.632986" };
            return gr;
        }
        if (nameString.equals("North China Electric Power University")) {
            String[] gr = { "40.089758", "116.309797" };
            return gr;
        }
        if (nameString.equals("Novosibirsk State Technical University")) {
            String[] gr = { "54.988", "82.904" };
            return gr;
        }
        if (nameString.equals("University at Buffalo, The State University of New York")) {
            String[] gr = { "43", "-78.79" };
            return gr;
        }
        if (nameString.equals("Augustana College")) {
            String[] gr = { "41.5023", "-90.5504" };
            return gr;
        }
        if (nameString.equals("Beijing Dance Academy")) {
            String[] gr = { "39.947997", "116.318956" };
            return gr;
        }
        if (nameString.equals("Beijing Forestry University")) {
            String[] gr = { "40.001389", "116.345278" };
            return gr;
        }
        if (nameString.equals("Beijing Information Science & Technology University")) {
            String[] gr = { "40.043319", "116.341811" };
            return gr;
        }
        if (nameString.equals("Birkbeck, University of London")) {
            String[] gr = { "51.521728", "-0.129338" };
            return gr;
        }
        if (nameString.equals("California State University, East Bay")) {
            String[] gr = { "37.656944", "-122.057778" };
            return gr;
        }
        if (nameString.equals("California State University, Fresno")) {
            String[] gr = { "36.813333", "-119.75" };
            return gr;
        }
        if (nameString.equals("California State University, Fullerton")) {
            String[] gr = { "33.880556", "-117.885278" };
            return gr;
        }
        if (nameString.equals("California State University, Los Angeles")) {
            String[] gr = { "34.066667", "-118.167778" };
            return gr;
        }
        if (nameString.equals("California State University, Long Beach")) {
            String[] gr = { "33.783022", "-118.112858" };
            return gr;
        }
        if (nameString.equals("California State University, Northridge")) {
            String[] gr = { "34.241667", "-118.528333" };
            return gr;
        }
        if (nameString.equals("California State University, Sacramento")) {
            String[] gr = { "38.560222", "-121.424111" };
            return gr;
        }
        if (nameString.equals("Central Conservatory of Music")) {
            String[] gr = { "39.903292", "116.3604" };
            return gr;
        }
        if (nameString.equals("Cheung Kong Graduate School of Business")) {
            String[] gr = { "39.909903", "116.416858" };
            return gr;
        }
        if (nameString.equals("China Central Academy of Fine Arts")) {
            String[] gr = { "31.218653", "121.474831" };
            return gr;
        }
        if (nameString.equals("Daqing Petroleum Institute")) {
            String[] gr = { "46.587919", "125.143075" };
            return gr;
        }
        if (nameString.equals("École normale supérieure de Lyon")) {
            String[] gr = { "45.729734", "4.82687" };
            return gr;
        }
        if (nameString.equals("Feng Chia University")) {
            String[] gr = { "24.181767", "120.648331" };
            return gr;
        }
        if (nameString.equals("Fujian Normal University")) {
            String[] gr = { "26.040031", "119.305514" };
            return gr;
        }
        if (nameString.equals("Georgetown College")) {
            String[] gr = { "38.207", "-84.554" };
            return gr;
        }
        if (nameString.equals("Harbin University of Commerce")) {
            String[] gr = { "45.818092", "126.564269" };
            return gr;
        }
        if (nameString.equals("Indian Institute of Technology, Jodhpur")) {
            String[] gr = { "26.271186", "73.032964" };
            return gr;
        }
        if (nameString.equals("King Saud University")) {
            String[] gr = { "24.722", "46.627" };
            return gr;
        }
        if (nameString.equals("Mayo Medical School")) {
            String[] gr = { "44.022136", "92.469303" };
            return gr;
        }
        if (nameString.equals("Nanjing Forestry University")) {
            String[] gr = { "32.080833", "118.811389" };
            return gr;
        }
        if (nameString.equals("Nanjing University of Science and Technology")) {
            String[] gr = { "32.0333", "118.851922" };
            return gr;
        }
        if (nameString.equals("Nanjing University of the Arts")) {
            String[] gr = { "32.066944", "118.750278" };
            return gr;
        }
        if (nameString.equals("National Defence University, Pakistan")) {
            String[] gr = { "33.721292", "73.022081" };
            return gr;
        }
        if (nameString.equals("National Sun Yat-sen University")) {
            String[] gr = { "22.626667", "120.265833" };
            return gr;
        }
        if (nameString.equals("North China Electric Power University")) {
            String[] gr = { "40.089758", "116.309797" };
            return gr;
        }
        if (nameString.equals("Panthéon-Assas University")) {
            String[] gr = { "48.846944", "2.344722" };
            return gr;
        }
        if (nameString.equals("Peking Union Medical College")) {
            String[] gr = { "39.911456", "116.414836" };
            return gr;
        }
        if (nameString.equals("Shanxi Teachers University")) {
            String[] gr = { "34.203086", "108.950236" };
            return gr;
        }
        if (nameString.equals("Simmons College")) {
            String[] gr = { "42.3398", "-71.1002" };
            return gr;
        }
        if (nameString.equals("St. John's University (New York City)")) {
            String[] gr = { "40.72194", "-73.79556" };
            return gr;
        }
        if (nameString.equals("Third Military Medical University")) {
            String[] gr = { "29.535058", "106.456328" };
            return gr;
        }
        if (nameString.equals("Tibet University")) {
            String[] gr = { "29.6459", "91.14541" };
            return gr;
        }
        if (nameString.equals("Trinity College, Dublin")) {
            String[] gr = { "53.3444", "-6.2577" };
            return gr;
        }
        if (nameString.equals("University at Albany, SUNY")) {
            String[] gr = { "42.686193", "-73.823884" };
            return gr;
        }
        if (nameString.equals("University of California, Berkeley")) {
            String[] gr = { "37.87", "-122.259" };
            return gr;
        }
        if (nameString.equals("University of California, Los Angeles")) {
            String[] gr = { "34.072222", "-118.444097" };
            return gr;
        }
        if (nameString.equals("University of California, Merced")) {
            String[] gr = { "37.366", "-120.4235" };
            return gr;
        }
        if (nameString.equals("University of California, Riverside")) {
            String[] gr = { "33.975556", "-117.331111" };
            return gr;
        }
        if (nameString.equals("University of California, San Diego")) {
            String[] gr = { "32.881", "-117.238" };
            return gr;
        }
        if (nameString.equals("University of California, San Francisco")) {
            String[] gr = { "37.763319", "-122.458539" };
            return gr;
        }
        if (nameString.equals("University of California, Santa Barbara")) {
            String[] gr = { "34.41254", "-119.84813" };
            return gr;
        }
        if (nameString.equals("University of California, Santa Cruz")) {
            String[] gr = { "37", "-122.06" };
            return gr;
        }
        if (nameString.equals("University of Colorado Boulder")) {
            String[] gr = { "40.006667", "-105.267222" };
            return gr;
        }
        if (nameString.equals("University of Helmstedt")) {
            String[] gr = { "52.229167", "11.008611" };
            return gr;
        }
        if (nameString.equals("University of Keele")) {
            String[] gr = { "53.003", "-2.273" };
            return gr;
        }
        if (nameString.equals("University of Lorraine")) {
            String[] gr = { "48.696111", "6.176667" };
            return gr;
        }
        if (nameString.equals("University of Maryland, Baltimore County")) {
            String[] gr = { "39.2555", "-76.711256" };
            return gr;
        }
        if (nameString.equals("University of Maryland, Baltimore")) {
            String[] gr = { "39.291389", "-76.625" };
            return gr;
        }
        if (nameString.equals("University of Rennes 1")) {
            String[] gr = { "48.117976", "-1.637993" };
            return gr;
        }
        if (nameString.equals("University of Technology, Sydney")) {
            String[] gr = { "33.883239", "151.200494" };
            return gr;
        }
        if (nameString.equals("Yanbian University")) {
            String[] gr = { "42.908056", "129.485278" };
            return gr;
        }
        if (nameString.equals("xxx")) {
            String[] gr = { "xxx", "xxx" };
            return gr;
        }

        String ret = getValue(nameString, "point");
        if (ret == null || ret.equals("NULL"))
            return null;
        String[] v = ret.split(" ");
        if (v.length != 2)
            return null;
        return v;
    }

    public String getCountryName(String nameString) {
        String countryname = getValue(nameString, "country_label");
        if (countryname == null || countryname.equals("NULL")) {
            countryname = getHardCodedCountryName(nameString);
            if (countryname == null || countryname.equals("NULL"))
                return null;
        }
        countryname = getLastWikiBag(countryname);
        return countryname;
    }

    public String getHardCodedCountryName(String nameString) {

        /**
         * added by ider
         */

        if (nameString.equals("xxxx")) {
            return "China";
        }
        if (nameString.equals("xxxx")) {
            return "China";
        }
        if (nameString.equals("Yanbian University")) {
            return "China";
        }
        if (nameString.equals("University of Technology, Sydney")) {
            return "Australia";
        }
        if (nameString.equals("University of Rennes 1")) {
            return "France";
        }
        if (nameString.equals("University of Massachusetts Medical School")) {
            return "United States";
        }
        if (nameString.equals("University of Maryland, Baltimore")) {
            return "United States";
        }
        if (nameString.equals("University of Maryland, Baltimore County")) {
            return "United States";
        }
        if (nameString.equals("University of Lorraine")) {
            return "France";
        }
        if (nameString.equals("University of Keele")) {
            return "United Kingdom";
        }
        if (nameString.equals("University of Helmstedt")) {
            return "Germany";
        }
        if (nameString.equals("University of Colorado Boulder")) {
            return "United States";
        }
        if (nameString.equals("University of California, Santa Cruz")) {
            return "United States";
        }
        if (nameString.equals("University of California, Santa Barbara")) {
            return "United States";
        }
        if (nameString.equals("University of California, San Francisco")) {
            return "United States";
        }
        if (nameString.equals("University of California, San Diego")) {
            return "United States";
        }
        if (nameString.equals("University of California, Riverside")) {
            return "United States";
        }
        if (nameString.equals("University of California, Merced")) {
            return "United States";
        }
        if (nameString.equals("University of California, Los Angeles")) {
            return "United States";
        }
        if (nameString.equals("University of California, Berkeley")) {
            return "United States";
        }
        if (nameString.equals("University at Albany, SUNY")) {
            return "United States";
        }
        if (nameString.equals("Trinity College, Dublin")) {
            return "Ireland";
        }
        if (nameString.equals("Tibet University")) {
            return "China";
        }
        if (nameString.equals("Third Military Medical University")) {
            return "China";
        }
        if (nameString.equals("St. John's University (New York City)")) {
            return "United States";
        }
        if (nameString.equals("Simmons College")) {
            return "United States";
        }
        if (nameString.equals("Shanxi Teachers University")) {
            return "China";
        }
        if (nameString.equals("Peking Union Medical College")) {
            return "China";
        }
        if (nameString.equals("Panthéon-Assas University")) {
            return "France";
        }
        if (nameString.equals("North China Electric Power University")) {
            return "China";
        }
        if (nameString.equals("National Defence University, Pakistan")) {
            return "Pakistan";
        }
        if (nameString.equals("Nanjing University of the Arts")) {
            return "China";
        }
        if (nameString.equals("Nanjing University of Science and Technology")) {
            return "China";
        }
        if (nameString.equals("Nanjing University of Information Science and Technology")) {
            return "China";
        }
        if (nameString.equals("Nanjing Forestry University")) {
            return "China";
        }
        if (nameString.equals("Indian Institute of Technology, Jodhpur")) {
            return "Indian";
        }
        if (nameString.equals("Harbin University of Commerce")) {
            return "China";
        }
        if (nameString.equals("Fujian Normal University")) {
            return "China";
        }
        if (nameString.equals("Feng Chia University")) {
            return "Taiwan";
        }
        if (nameString.equals("École normale supérieure de Lyon")) {
            return "France";
        }
        if (nameString.equals("Daqing Petroleum Institute")) {
            return "China";
        }
        if (nameString.equals("China Medical University")) {
            return "China";
        }
        if (nameString.equals("China Central Academy of Fine Arts")) {
            return "China";
        }
        if (nameString.equals("Cheung Kong Graduate School of Business")) {
            return "China";
        }
        if (nameString.equals("Central Conservatory of Music")) {
            return "China";
        }
        if (nameString.equals("California State University, Sacramento")) {
            return "United States";
        }
        if (nameString.equals("California State University, Los Angeles")) {
            return "United States";
        }
        if (nameString.equals("California State University, Fullerton")) {
            return "United States";
        }
        if (nameString.equals("California State University, Fresno")) {
            return "United States";
        }
        if (nameString.equals("California State University, East Bay")) {
            return "United States";
        }
        if (nameString.equals("Birkbeck, University of London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Beijing Information Science & Technology University")) {
            return "China";
        }
        if (nameString.equals("Beijing Forestry University")) {
            return "China";
        }
        if (nameString.equals("Beijing Dance Academy")) {
            return "China";
        }
        if (nameString.equals("Augustana College")) {
            return "United States";
        }
        if (nameString.equals("Tokyo Institute of Technology")) {
            return "Japan";
        }
        if (nameString.equals("Southwestern University of Finance and Economics")) {
            return "China";
        }
        if (nameString.equals("Shanghai University of Finance and Economics")) {
            return "China";
        }
        if (nameString.equals("North China Electric Power University")) {
            return "China";
        }
        if (nameString.equals("Sun Yat-sen University")) {
            return "China";
        }
        if (nameString.equals("Zhejiang University of Technology")) {
            return "China";
        }
        if (nameString.equals("Yunnan University")) {
            return "China";
        }
        if (nameString.equals("Yangzhou University")) {
            return "China";
        }
        if (nameString.equals("Xuzhou Medical College")) {
            return "China";
        }
        if (nameString.equals("Xi'an Jiaotong University")) {
            return "China";
        }
        if (nameString.equals("Xiamen University")) {
            return "China";
        }
        if (nameString.equals("Wuhan University")) {
            return "China";
        }
        if (nameString.equals("Waseda University")) {
            return "Japan";
        }
        if (nameString.equals("University of the Punjab")) {
            return "Pakistan";
        }
        if (nameString.equals("University of the Chinese Academy of Sciences")) {
            return "China";
        }
        if (nameString.equals("University of Strathclyde")) {
            return "United Kingdom";
        }
        if (nameString.equals("University of Regensburg")) {
            return "Germany";
        }
        if (nameString.equals("University of International Relations")) {
            return "China";
        }
        if (nameString.equals("University of Electronic Science and Technology of China")) {
            return "China";
        }
        if (nameString.equals("University of Central Lancashire")) {
            return "United Kingdom";
        }
        if (nameString.equals("Tsinghua University")) {
            return "China";
        }
        if (nameString.equals("Meguro Tokyo")) {
            return "Japan";
        }
        if (nameString.equals("Taiyuan University of Technology")) {
            return "China";
        }
        if (nameString.equals("Aix-Marseille University")) {
            return "France";
        }
        if (nameString.equals("Ave Maria University")) {
            return "United States";
        }
        if (nameString.equals("Beijing Language and Culture University")) {
            return "China";
        }
        if (nameString.equals("Capital Normal University")) {
            return "China";
        }
        if (nameString.equals("Beijing Language and Culture University")) {
            return "China";
        }
        if (nameString.equals("Central Academy of Drama")) {
            return "China";
        }
        if (nameString.equals("Beijing Language and Culture University")) {
            return "China";
        }
        if (nameString.equals("Central South University")) {
            return "China";
        }
        if (nameString.equals("Central University of Finance and Economics")) {
            return "China";
        }
        if (nameString.equals("Chang Gung University")) {
            return "Taiwan";
        }
        if (nameString.equals("Chengdu University of Technology")) {
            return "China";
        }
        if (nameString.equals("China Agricultural University")) {
            return "China";
        }
        if (nameString.equals("China Foreign Affairs University")) {
            return "China";
        }
        if (nameString.equals("China Pharmaceutical University")) {
            return "China";
        }
        if (nameString.equals("China University of Mining and Technology")) {
            return "China";
        }
        if (nameString.equals("China University of Petroleum")) {
            return "China";
        }
        if (nameString.equals("City University of Hong Kong")) {
            return "Hong Kong";
        }
        if (nameString.equals("Dalian Maritime University")) {
            return "China";
        }
        if (nameString.equals("Dalian University of Technology")) {
            return "China";
        }
        if (nameString.equals("East China University of Political Science and Law")) {
            return "China";
        }
        if (nameString.equals("Fourth Military Medical University")) {
            return "China";
        }
        if (nameString.equals("Fudan University")) {
            return "China";
        }
        if (nameString.equals("Fullerton College")) {
            return "United States";
        }
        if (nameString.equals("Fuzhou University")) {
            return "China";
        }
        if (nameString.equals("Guizhou University")) {
            return "China";
        }
        if (nameString.equals("Harbin Engineering University")) {
            return "China";
        }
        if (nameString.equals("Harbin Institute of Technology")) {
            return "China";
        }
        if (nameString.equals("Hohai University")) {
            return "China";
        }
        if (nameString.equals("Hong Kong Baptist University")) {
            return "Hong Kong";
        }
        if (nameString.equals("Hunan University")) {
            return "China";
        }
        if (nameString.equals("Inner Mongolia University")) {
            return "China";
        }
        if (nameString.equals("Jiangnan University")) {
            return "China";
        }
        if (nameString.equals("Jiangsu University")) {
            return "China";
        }
        if (nameString.equals("Jilin University")) {
            return "China";
        }
        if (nameString.equals("Jinan University")) {
            return "China";
        }
        if (nameString.equals("Joseph Fourier University")) {
            return "France";
        }
        if (nameString.equals("Kyushu University")) {
            return "Japan";
        }
        if (nameString.equals("Lanzhou University")) {
            return "China";
        }
        if (nameString.equals("Lingnan University (Hong Kong)")) {
            return "Hong Kong";
        }
        if (nameString.equals("London Academy of Music and Dramatic Art")) {
            return "United Kingdom";
        }
        if (nameString.equals("Medical University of South Carolina")) {
            return "United States";
        }
        if (nameString.equals("Nanchang University")) {
            return "China";
        }
        if (nameString.equals("Nanjing University of Finance and Economics")) {
            return "China";
        }
        if (nameString.equals("Nanjing University of Finance and Economics")) {
            return "China";
        }
        if (nameString.equals("Nanjing University")) {
            return "China";
        }
        if (nameString.equals("Nantong University")) {
            return "China";
        }
        if (nameString.equals("National Central University")) {
            return "Taiwan";
        }
        if (nameString.equals("Northeast Agricultural University")) {
            return "China";
        }
        if (nameString.equals("Northeast Forestry University")) {
            return "China";
        }
        if (nameString.equals("Northeast Normal University")) {
            return "China";
        }
        if (nameString.equals("Northeastern University (China)")) {
            return "China";
        }
        if (nameString.equals("Northwest University (China)")) {
            return "China";
        }
        if (nameString.equals("Northwestern Polytechnical University")) {
            return "China";
        }
        if (nameString.equals("Novosibirsk State University")) {
            return "Russia";
        }
        if (nameString.equals("Osaka City University")) {
            return "Japan";
        }
        if (nameString.equals("Peking University")) {
            return "China";
        }
        if (nameString.equals("Qingdao University")) {
            return "China";
        }
        if (nameString.equals("Qufu Normal University")) {
            return "China";
        }
        if (nameString.equals("Second Military Medical University")) {
            return "China";
        }
        if (nameString.equals("Shaanxi Normal University")) {
            return "China";
        }
        if (nameString.equals("Shandong Normal University")) {
            return "China";
        }
        if (nameString.equals("Shandong University of Science and Technology")) {
            return "China";
        }
        if (nameString.equals("Shandong University")) {
            return "China";
        }
        if (nameString.equals("Shanghai International Studies University")) {
            return "China";
        }
        if (nameString.equals("Shanghai University")) {
            return "China";
        }
        if (nameString.equals("Shanxi University")) {
            return "China";
        }
        if (nameString.equals("Sichuan University")) {
            return "China";
        }
        if (nameString.equals("Soochow University (Suzhou)")) {
            return "China";
        }
        if (nameString.equals("South China Normal University")) {
            return "China";
        }
        if (nameString.equals("Southwest Jiaotong University")) {
            return "China";
        }

        if (nameString.equals("Harvard University")) {
            return "United States";
        }
        if (nameString.equals("Columbia University")) {
            return "United States";
        }
        if (nameString.equals("Stanford University")) {
            return "United States";
        }
        if (nameString.equals("University of Michigan")) {
            return "United States";
        }
        if (nameString.equals("Massachusetts Institute of Technology")) {
            return "United States";
        }
        if (nameString.equals("Princeton University")) {
            return "United States";
        }
        if (nameString.equals("New York University")) {
            return "United States";
        }
        if (nameString.equals("University of Chicago")) {
            return "United States";
        }
        if (nameString.equals("Cornell University")) {
            return "United States";
        }
        if (nameString.equals("University of Pennsylvania")) {
            return "United States";
        }
        if (nameString.equals("University of Wisconsin–Madison")) {
            return "United States";
        }
        if (nameString.equals("University of Illinois at Urbana–Champaign")) {
            return "United States";
        }
        if (nameString.equals("University of Minnesota")) {
            return "United States";
        }
        if (nameString.equals("Northwestern University")) {
            return "United States";
        }
        if (nameString.equals("University of Washington")) {
            return "United States";
        }
        if (nameString.equals("Brown University")) {
            return "United States";
        }
        if (nameString.equals("University of Maryland, College Park")) {
            return "United States";
        }
        if (nameString.equals("Pennsylvania State University")) {
            return "United States";
        }
        if (nameString.equals("University of Notre Dame")) {
            return "United States";
        }
        if (nameString.equals("Boston University")) {
            return "United States";
        }
        if (nameString.equals("Dartmouth College")) {
            return "United States";
        }
        if (nameString.equals("Michigan State University")) {
            return "United States";
        }
        if (nameString.equals("University of Sydney")) {
            return "Australia";
        }
        if (nameString.equals("Syracuse University")) {
            return "United States";
        }
        if (nameString.equals("University of Pittsburgh")) {
            return "United States";
        }
        if (nameString.equals("University of Missouri")) {
            return "United States";
        }
        if (nameString.equals("University of Arizona")) {
            return "United States";
        }
        if (nameString.equals("California Institute of Technology")) {
            return "United States";
        }
        if (nameString.equals("Purdue University")) {
            return "United States";
        }
        if (nameString.equals("Carnegie Mellon University")) {
            return "United States";
        }
        if (nameString.equals("Florida State University")) {
            return "United States";
        }
        if (nameString.equals("University of Miami")) {
            return "United States";
        }
        if (nameString.equals("University of Tennessee")) {
            return "United States";
        }
        if (nameString.equals("University of Utah")) {
            return "United States";
        }
        if (nameString.equals("University of Oregon")) {
            return "United States";
        }
        if (nameString.equals("University of Kentucky")) {
            return "United States";
        }
        if (nameString.contains("University of Nebraska")) {
            return "United States";
        }
        if (nameString.equals("Imperial College London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Washington University in St. Louis")) {
            return "United States";
        }
        if (nameString.equals("Temple University")) {
            return "United States";
        }
        if (nameString.equals("University of Birmingham")) {
            return "United Kingdom";
        }
        if (nameString.equals("Tulane University")) {
            return "United States";
        }
        if (nameString.equals("University of Bristol")) {
            return "United Kingdom";
        }
        if (nameString.equals("Australian National University")) {
            return "Australia";
        }
        if (nameString.equals("Queen's University")) {
            return "Canada";
        }
        if (nameString.equals("University of Houston")) {
            return "United States";
        }
        if (nameString.equals("University of California, Santa Barbara")) {
            return "United States";
        }
        if (nameString.equals("North Carolina State University")) {
            return "United States";
        }
        if (nameString.equals("University of California, Davis")) {
            return "United States";
        }
        if (nameString.equals("Virginia Tech")) {
            return "United States";
        }
        if (nameString.equals("University of Cincinnati")) {
            return "United States";
        }
        if (nameString.equals("University of Arkansas")) {
            return "United States";
        }
        if (nameString.equals("Emory University")) {
            return "United States";
        }
        if (nameString.equals("Wesleyan University")) {
            return "United States";
        }
        if (nameString.equals("Southern Methodist University")) {
            return "United States";
        }
        if (nameString.equals("City College of New York")) {
            return "United States";
        }
        if (nameString.equals("University of California, Irvine")) {
            return "United States";
        }
        if (nameString.equals("University of Aberdeen")) {
            return "United Kingdom";
        }
        if (nameString.equals("University at Buffalo, The State University of New York")) {
            return "United States";
        }
        if (nameString.equals("University of Delaware")) {
            return "United States";
        }
        if (nameString.equals("Williams College")) {
            return "United States";
        }
        if (nameString.equals("Oberlin College")) {
            return "United States";
        }
        if (nameString.equals("University of New Mexico")) {
            return "United States";
        }
        if (nameString.equals("San Diego State University")) {
            return "United States";
        }
        if (nameString.equals("Washington State University")) {
            return "United States";
        }
        if (nameString.equals("Ohio University")) {
            return "United States";
        }
        if (nameString.equals("Smith College")) {
            return "United States";
        }
        if (nameString.equals("University of Warwick")) {
            return "United Kingdom";
        }
        if (nameString.equals("George Mason University")) {
            return "United States";
        }
        if (nameString.equals("University of Saskatchewan")) {
            return "Canada";
        }
        if (nameString.equals("University of South Florida")) {
            return "United States";
        }
        if (nameString.equals("Northeastern University")) {
            return "United States";
        }
        if (nameString.equals("University of California, Santa Cruz")) {
            return "United States";
        }
        if (nameString.equals("Newcastle University")) {
            return "United Kingdom";
        }
        if (nameString.equals("University of Warsaw")) {
            return "Poland";
        }
        if (nameString.equals("University of Wyoming")) {
            return "United States";
        }
        if (nameString.equals("Utah State University")) {
            return "United States";
        }
        if (nameString.equals("University of Reading")) {
            return "United Kingdom";
        }
        if (nameString.equals("University of York")) {
            return "United Kingdom";
        }
        if (nameString.equals("Barnard College")) {
            return "United States";
        }
        if (nameString.equals("Lehigh University")) {
            return "United States";
        }
        if (nameString.equals("Bowdoin College")) {
            return "United States";
        }
        if (nameString.equals("University of Montana")) {
            return "United States";
        }
        if (nameString.equals("Colgate University")) {
            return "United States";
        }
        if (nameString.equals("Santa Clara University")) {
            return "United States";
        }
        if (nameString.equals("Virginia Military Institute")) {
            return "United States";
        }
        if (nameString.equals("California State University, Long Beach")) {
            return "United States";
        }
        if (nameString.equals("Virginia Commonwealth University")) {
            return "United States";
        }
        if (nameString.equals("University of Illinois at Chicago")) {
            return "United States";
        }
        if (nameString.equals("Yeshiva University")) {
            return "United States";
        }
        if (nameString.equals("Goldsmiths, University of London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Cooper Union")) {
            return "United States";
        }
        if (nameString.equals("University of Victoria")) {
            return "Canada";
        }
        if (nameString.equals("University of California, San Francisco")) {
            return "United States";
        }
        if (nameString.equals("Washington & Jefferson College")) {
            return "United States";
        }
        if (nameString.equals("California State University, Northridge")) {
            return "United States";
        }
        if (nameString.equals("University of Strasbourg")) {
            return "France";
        }
        if (nameString.equals("University of Kent")) {
            return "United Kingdom";
        }
        if (nameString.equals("Macquarie University")) {
            return "Australia";
        }
        if (nameString.equals("University of Rhode Island")) {
            return "United States";
        }
        if (nameString.equals("Queen Mary, University of London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Lancaster University")) {
            return "United Kingdom";
        }
        if (nameString.equals("Goethe University Frankfurt")) {
            return "Germany";
        }
        if (nameString.equals("Rockefeller University")) {
            return "United States";
        }
        if (nameString.equals("University of Essex")) {
            return "United Kingdom";
        }
        if (nameString.equals("California Polytechnic State University")) {
            return "United States";
        }
        if (nameString.equals("Kenyon College")) {
            return "United States";
        }
        if (nameString.equals("Delft University of Technology")) {
            return "Netherlands";
        }
        if (nameString.equals("Royal Holloway, University of London")) {
            return "United Kingdom";
        }
        if (nameString.equals("University of Surrey")) {
            return "United Kingdom";
        }
        if (nameString.equals("Reed College")) {
            return "United States";
        }
        if (nameString.equals("Carleton College")) {
            return "United States";
        }
        if (nameString.equals("Franklin & Marshall College")) {
            return "United States";
        }
        if (nameString.equals("Bennington College")) {
            return "United States";
        }
        if (nameString.equals("Willamette University")) {
            return "United States";
        }
        if (nameString.equals("Gettysburg College")) {
            return "United States";
        }
        if (nameString.equals("State University of New York at Purchase")) {
            return "United States";
        }
        if (nameString.equals("Macalester College")) {
            return "United States";
        }
        if (nameString.equals("Spelman College")) {
            return "United States";
        }
        if (nameString.equals("Allegheny College")) {
            return "United States";
        }
        if (nameString.equals("Connecticut College")) {
            return "United States";
        }
        if (nameString.equals("Wittenberg University")) {
            return "United States";
        }
        if (nameString.equals("Lewis & Clark College")) {
            return "United States";
        }
        if (nameString.equals("College of Saint Benedict and Saint John's University")) {
            return "United States";
        }
        if (nameString.equals("Ruhr University Bochum")) {
            return "Germany";
        }
        if (nameString.equals("Siena College")) {
            return "United States";
        }
        if (nameString.equals("University of Texas Southwestern Medical Center")) {
            return "United States";
        }
        if (nameString.equals("Tohoku University")) {
            return "Japan";
        }
        if (nameString.equals("Hope College")) {
            return "United States";
        }
        if (nameString.equals("Gustavus Adolphus College")) {
            return "United States";
        }
        if (nameString.equals("Southwestern University")) {
            return "United States";
        }
        if (nameString.equals("Berea College")) {
            return "United States";
        }
        if (nameString.equals("Concordia College (Moorhead, Minnesota)")) {
            return "United States";
        }
        if (nameString.equals("Thomas Jefferson University")) {
            return "United States";
        }
        if (nameString.equals("Linfield College")) {
            return "United States";
        }
        if (nameString.equals("Grove City College")) {
            return "United States";
        }
        if (nameString.equals("Moravian College")) {
            return "United States";
        }
        if (nameString.equals("Guilford College")) {
            return "United States";
        }
        if (nameString.equals("Austin College")) {
            return "United States";
        }
        if (nameString.equals("University of Duisburg-Essen")) {
            return "Germany";
        }
        if (nameString.equals("Coe College")) {
            return "United States";
        }
        if (nameString.equals("	Westminster College (Utah)")) {
            return "United States";
        }
        if (nameString.equals("St. Mary's College of Maryland")) {
            return "United States";
        }
        if (nameString.equals("University of Minnesota Morris")) {
            return "United States";
        }
        if (nameString.equals("Wartburg College")) {
            return "United States";
        }
        if (nameString.equals("Worcester Polytechnic Institute")) {
            return "United States";
        }
        if (nameString.equals("Fordham University")) {
            return "United States";
        }
        if (nameString.equals("Clark University")) {
            return "United States";
        }
        if (nameString.equals("Florida Institute of Technology")) {
            return "United States";
        }
        if (nameString.equals("The New School")) {
            return "United States";
        }
        if (nameString.equals("University of Maine")) {
            return "United States";
        }
        if (nameString.equals("University of Alabama")) {
            return "United States";
        }
        if (nameString.equals("Royal College of Music")) {
            return "United Kingdom";
        }
        if (nameString.equals("Antioch College")) {
            return "United States";
        }
        if (nameString.equals("University of Denver")) {
            return "United States";
        }
        if (nameString.equals("Marquette University")) {
            return "United States";
        }
        if (nameString.equals("University of Wisconsin–Milwaukee")) {
            return "United States";
        }
        if (nameString.equals("INSEAD")) {
            return "France";
        }
        if (nameString.equals("Binghamton University")) {
            return "United States";
        }
        if (nameString.equals("Westminster College (Utah)")) {
            return "United States";
        }
        if (nameString.equals("Duquesne University")) {
            return "United States";
        }
        if (nameString.equals("Indian Institute of Technology Kanpur")) {
            return "India";
        }
        if (nameString.equals("Indian Institute of Technology (BHU) Varanasi")) {
            return "India";
        }
        if (nameString.equals("City Law School")) {
            return "United Kingdom";
        }
        if (nameString.contains("Texas State University")) {
            return "United States";
        }
        if (nameString.equals("University of Harderwijk")) {
            return "Netherlands";
        }
        if (nameString.equals("London Academy of Music and Dramatic Art")) {
            return "United Kingdom";
        }
        if (nameString.equals("Pennsylvania Academy of the Fine Arts")) {
            return "United States";
        }
        if (nameString.equals("École nationale d'administration")) {
            return "France";
        }
        if (nameString.equals("Royal Military Academy Sandhurst")) {
            return "United Kingdom";
        }
        if (nameString.equals("Ohio Central College")) {
            return "United States";
        }
        if (nameString.equals("Graz University of Technology")) {
            return "Austria";
        }
        if (nameString.equals("Pantheon-Sorbonne University")) {
            return "France";
        }
        if (nameString.equals("Paris West University Nanterre La Défense")) {
            return "France";
        }
        if (nameString.equals("Western Washington University")) {
            return "United States";
        }
        if (nameString.equals("United States Military Academy")) {
            return "United States";
        }
        if (nameString.equals("University College London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Juilliard School")) {
            return "United States";
        }
        if (nameString.equals("Heidelberg University")) {
            return "Germany";
        }
        if (nameString.equals("University of Göttingen")) {
            return "Germany";
        }
        if (nameString.equals("Leiden University")) {
            return "Netherlands";
        }
        if (nameString.equals("Monash University")) {
            return "Australia";
        }
        if (nameString.equals("National Autonomous University of Mexico")) {
            return "Mexico";
        }
        if (nameString.equals("University of Adelaide")) {
            return "Australia";
        }
        if (nameString.equals("Martin Luther University of Halle-Wittenberg")) {
            return "Germany";
        }
        if (nameString.equals("University of Tübingen")) {
            return "Germany";
        }
        if (nameString.equals("University of Freiburg")) {
            return "Germany";
        }
        if (nameString.equals("VU University Amsterdam")) {
            return "Netherlands";
        }
        if (nameString.equals("University of Zurich")) {
            return "Switzerland";
        }
        if (nameString.equals("University of Marburg")) {
            return "Germany";
        }
        if (nameString.equals("Complutense University of Madrid")) {
            return "Spain";
        }
        if (nameString.equals("University of Hawaii at Manoa")) {
            return "United States";
        }
        if (nameString.equals("Ghent University")) {
            return "Belgium";
        }
        if (nameString.equals("Technical University Munich")) {
            return "Germany";
        }
        if (nameString.equals("University of Basel")) {
            return "Switzerland";
        }
        if (nameString.equals("University of Münster")) {
            return "Germany";
        }
        if (nameString.equals("Karlsruhe Institute of Technology")) {
            return "Germany";
        }
        if (nameString.equals("University of Giessen")) {
            return "Germany";
        }
        if (nameString.equals("Indian Institute of Science")) {
            return "India";
        }
        if (nameString.equals("University of Mainz")) {
            return "Germany";
        }
        if (nameString.equals("Curtin University")) {
            return "Australia";
        }
        if (nameString.equals("University of Innsbruck")) {
            return "Austria";
        }
        if (nameString.equals("RWTH Aachen University")) {
            return "Germany";
        }
        if (nameString.equals("Ben-Gurion University of the Negev")) {
            return "Israel";
        }
        if (nameString.equals("Massey University")) {
            return "New Zealand";
        }
        if (nameString.equals("Flinders University")) {
            return "Australia";
        }
        if (nameString.equals("Dresden University of Technology")) {
            return "Germany";
        }
        if (nameString.equals("University of Milan")) {
            return "Italy";
        }
        if (nameString.equals("Radboud University Nijmegen")) {
            return "Netherlands";
        }
        if (nameString.equals("University of Greenwich")) {
            return "United Kingdom";
        }
        if (nameString.equals("Icahn School of Medicine at Mount Sinai")) {
            return "United States";
        }
        if (nameString.equals("United Nations University")) {
            return "Japan";
        }
        if (nameString.equals("University of Bordeaux")) {
            return "France";
        }
        if (nameString.equals("University of Toulouse")) {
            return "France";
        }
        if (nameString.equals("Autonomous University of Barcelona")) {
            return "Spain";
        }
        if (nameString.equals("University of Texas MD Anderson Cancer Center")) {
            return "United States";
        }

        if (nameString.equals("University of Antwerp")) {
            return "Belgium";
        }
        if (nameString.equals("McDaniel College")) {
            return "United States";
        }
        if (nameString.equals("University of Bremen")) {
            return "Germany";
        }
        if (nameString.equals("University of Düsseldorf")) {
            return "Germany";
        }
        if (nameString.equals("Pompeu Fabra University")) {
            return "Spain";
        }
        if (nameString.equals("SUNY Downstate Medical Center")) {
            return "United States";
        }
        if (nameString.equals("University of Ulm")) {
            return "Germany";
        }
        if (nameString.equals("Mayo Medical School")) {
            return "United States";
        }
        if (nameString.equals("University of National and World Economy")) {
            return "Bulgaria";
        }
        if (nameString.equals("Lyon College")) {
            return "United States";
        }
        if (nameString.equals("University of International Business and Economics")) {
            return "China";
        }
        if (nameString.equals("Bryn Athyn College")) {
            return "United States";
        }
        if (nameString.equals("Georgetown College")) {
            return "United States";
        }
        if (nameString.contains("Brunel University")) {
            return "United Kingdom";
        }
        if (nameString.equals("Aston University")) {
            return "United Kingdom";
        }
        if (nameString.equals("City University London")) {
            return "United Kingdom";
        }
        if (nameString.equals("Beihang University")) {
            return "China";
        }

        return null;
    }

    static String getLastWikiBag(String str) {
        if (str == null)
            return null;
        String ret = str.trim();
        if (ret.startsWith("{")) {
            ret = ret.substring(1, (ret.length() - 1));
            if (ret.contains("|"))
                ret = ret.substring(ret.lastIndexOf('|') + 1);
        }
        return ret;
    }

    public String getState(String nameString) {
        return getValue(nameString, "state");
    }

    public String getNickName(String nameString) {
        return getValue(nameString, "nick");
    }

    public String getHomePage(String nameString) {
        String url = getRawValue(nameString, "homepage");
        try {
            new java.net.URL(url);
            return url;
        } catch (java.net.MalformedURLException mfe) {
            return null;
        }
    }

    public String getWikiURL(String nameString) {
        String wikiPrefix = "http://en.wikipedia.org/wiki/";
        return (wikiPrefix + nameString.replace(' ', '_'));
    }

    public String printHTML(String nameString) {
        String[] row = nameMap.get(nameString);
        if (row == null)
            return null;

        String ret = "<table>";

        for (int i = 0; i < row.length; i++) {
            String propertyName = row0[i];
            String value = row[i];
            if (value.equalsIgnoreCase("NULL"))
                continue;
            ret += "<tr><td>" + propertyName + "</td><td>" + value;
            ret += "</tr>\n";
        }
        ret += "</table>\n";
        return ret;
    }

    // public static String getArticleTitle(WikiDB wikidb, String noCommaTitle,
    // String resourceString) {
    public static String getArticleTitle(String noCommaTitle, String resourceString) {
        String a = noCommaTitle.trim(); // wikidb.getArticleTitleByTitle(noCommaTitle);
        // if the noCommaTitle is not the right name, it could be the case that
        // the comma was replaced by whitespace
        if (a != null)
            return a;

        int ri = resourceString.lastIndexOf('/');
        String nameString = resourceString.trim();
        if (ri >= 0)
            nameString = nameString.substring(ri + 1).trim();
        nameString = nameString.replace('_', ' ');
        a = nameString; // wikidb.getArticleTitleByTitle(nameString);
        return a;
    }

    public static String getSchoolProperty(DBpediaTable db, String sname, String propertyName, String label, String cnlabel,boolean isChinese) {
        String pv = db.getValue(sname, propertyName);
        if (pv != null && !pv.equals("NULL")) {
            if(isChinese)
                return "<tr><td>" + cnlabel + "</td><td>" + pv + "</td></tr>\n";
            else
                return "<tr><td>" + label + "</td><td>" + pv + "</td></tr>\n";
        }
        return null;
    }

    public static String getSchoolPropertyMoney(DBpediaTable db, String sname, String propertyName, String label, String cnlabel,boolean isChinese) {
        String pv = db.getValue(sname, propertyName);
        if (pv == null || pv.equals("NULL"))
            return null;

        double nu;
        try {
            nu = Double.valueOf(pv);
        } catch (NumberFormatException nfe) {
            System.out.println(sname + ":" + pv);
            if(isChinese)
                return "<tr><td>" + cnlabel + "</td><td>" + pv + "</td></tr>\n";
            else
                return "<tr><td>" + label + "</td><td>" + pv + "</td></tr>\n";
        }

        if (nu >= billion) {
            nu = nu / billion;
            BigDecimal bd = new BigDecimal(nu);
            bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
            nu = bd.doubleValue();
            if(isChinese)
                return "<tr><td>" + cnlabel + "</td><td>" + nu + " billion</td></tr>\n";
            else
                return "<tr><td>" + label + "</td><td>" + nu + " billion</td></tr>\n";
        } else if (nu >= million) {
            nu = nu / million;
            BigDecimal bd = new BigDecimal(nu);
            bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
            nu = bd.doubleValue();
            if(isChinese )
                return "<tr><td>" + cnlabel + "</td><td>" + nu + " million</td></tr>\n";
            else
                return "<tr><td>" + label + "</td><td>" + nu + " million</td></tr>\n";
        }
        if(isChinese )
            return "<tr><td>" + cnlabel + "</td><td>" + nu + "</td></tr>\n";
        else
            return "<tr><td>" + label + "</td><td>" + nu + "</td></tr>\n";
    }

    public static String getSchoolPropertyDate(DBpediaTable db, String sname, String propertyName, String label, String cnlabel,boolean isChinese) {
        String pv = db.getValue(sname, propertyName);
        if (pv == null || pv.equals("NULL"))
            return null;
        Date date = parseDate(pv);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        if (date != null)
            pv = format.format(date);
        if(isChinese)
            return "<tr><td>" + cnlabel + "</td><td>" + pv + "</td></tr>\n";
        else
            return "<tr><td>" + label + "</td><td>" + pv + "</td></tr>\n";
    }

    public static String getSchoolPropertyDateYear(DBpediaTable db, String sname, String propertyName, String label, String cnlabel,boolean isChinese) {
        String pv = db.getValue(sname, propertyName);
        if (pv == null || pv.equals("NULL"))
            return null;
        Date date = parseDate(pv);
        SimpleDateFormat format = new SimpleDateFormat("yyyy");
        if (date != null)
            pv = format.format(date);
        if(isChinese)
            return "<tr><td>" + cnlabel + "</td><td>" + pv + "</td></tr>\n";
        else
            return "<tr><td>" + label + "</td><td>" + pv + "</td></tr>\n";

    }

    /**
     * get HTML of the given school(a high school, college, or university) that
     * is specified by the Article
     * 
     * @param db
     * @param article
     * @param cname
     * @return HTML text
     */
    public static String getSchoolHTML(DBpediaTable db, String schoolName, boolean isChinese) {
        int width = 480;
        int adsWidth = 120;
        int actualHeight = 5;
        int imageWidth = 400;
        if (schoolName == null)
            return null;

        String sname = schoolName;
        String pv, pv1;
        String ret = "<html><meta  http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\" /><head>\n";
        String[] geo = db.getGeoPoint(sname);
        String mapString = "";
        if (geo != null && geo.length == 2) {
            mapString = db.getMapScript().replace("XXXXX", geo[0]).replace("YYYYY", geo[1]);
            ret += mapString;
        } else
            geo = null;

        ret += "<style type=\"text/css\">a {text-decoration:none}</style></head><body leftmargin=\"10\" bottommargin=\"10\">\n";
        ret += "<table align=\"center\">";
        
        //added by ider
        if(isChinese&&!db.name_cn.get(sname).isEmpty()){
            ret += "<tr><td align=\"center\"><h3><center>" + db.name_cn.get(sname) +"<br>" + sname + "</center></h3></td></tr>\n";
        }else{
            ret += "<tr><td align=\"center\"><h3><center>" + sname + "</center></h3></td></tr>\n";
        }
        ret += "<tr cellspacing=\"35\"><td valign=\"top\">";
        ret += "<table align=\"center\" width=\"" + width + "\" border=\"0\" cellspacing=\"0\">";

        String fp = null;
        WikiModel wikiModel = new WikiModel("http://en.wikipedia.org/wiki/${image}",
                "http://en.wikipedia.org/wiki/${title}");
        try {

            // fp = db.wikiDB.getFirstParagraphMarkup(sname);
            // XXX need to fetch first paragraph
            fp = wikiModel.render(fp);
        } catch (Exception e) {
            fp = null;
        }
        
        //added by ider
        String Instruct = null;
        if(isChinese&&!db.nameInstruct_cn.get(sname).isEmpty()){
            Instruct = db.nameInstruct_cn.get(sname);
        }else{
            Instruct = db.nameInstruct.get(sname);
        }
        if (Instruct != null && !Instruct.equals("NULL")) {
            ret += "<tr><td  colspan=\"2\">" + Instruct + "</td></tr>\n";
            actualHeight++;
        }

        if (fp != null) {
            ret += "<tr><td colspan=\"2\">" + fp + "</td></tr>\n";

            ret += "<tr align=\"middle\"><td colspan=\"2\"><hr width=\"" + (width) + "\" size=\"1\"/></td></tr>";
        }

        pv = db.getAddress(sname);
        if (pv != null && !pv.equals("NULL")) {
            if(isChinese)  
                ret += "<tr><td width=\"90\">地址</td><td>" + pv + "</td></tr>\n";
            else
                ret += "<tr><td width=\"90\">Address</td><td>" + pv + "</td></tr>\n";
            actualHeight++;
        }


        if (geo != null && geo.length == 2) {
            ret += "<tr><td colspan=\"2\" align=\"center\"><div id=\"myMap\"  style=\"position:relative;width:"
                    + (width - 20) + "px;height:240px;\"></div></td></tr>\n";
            actualHeight += 10;
        }
        pv = getSchoolProperty(db, sname, "abbreviation", "Abbreviation","缩写",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "motto", "Motto","座右铭",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "slogan", "Slogan","口号",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "affiliation_label", "Affiliation","组织",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "rival_label", "Rival","对手",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "president_label", "President","校长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "superintendent", "Superintendent","学区",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "principal_label", "Principal","校长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "vicePrincipal_label", "Vice Principal","副校长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "assistantPrincipal_label", "Assistant Principal","副校长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "rector", "Rector","校长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "chairperson_label", "Chairperson","系主任",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "dean_label", "Dean","院长",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "director_label", "Director","主任",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "headLabel", "Head","主管",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "headteacher_label", "Headteacher","主任教师",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "chaplain_label", "Chaplain","牧师",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "officerInCharge_label", "Officer in Charge","主管",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "facultySize", "Faculty Size","师资规模",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "staff", "Staff","职员",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "teachingStaff", "Teaching Staff","教职员",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "numberOfStudents", "Number of Students","学生数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "numberOfDoctoralStudents", "Number of Doctoral Students","博士生数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "numberOfPostgraduateStudents", "Number of Postgraduate Students","研究生数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "numberOfUndergraduateStudents", "Number of Undergraduate Students","本科生数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "trustee", "Trustee","受托人",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "actScore_label", "ACT Score","ACT 分数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "satScore_label", "SAT Score","SAT 分数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "ceeb", "CEEB","CEEB代码",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "testAverage", "Test Average","测验平均分数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "denomination_label", "Denomination","类别",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "budget", "Budget","预算",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyMoney(db, sname, "endowment", "Endowment","获捐赠",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "revenue", "Revenue","营收",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "tuition", "Tuition","学费",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "fees", "Fees","费用",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "ageRange", "Age Range","年龄范围",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "lowerAge", "Lower Age","低龄",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "upperAge", "Upper Age","高龄",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "grades_label", "Grades","考试评分",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "alumni_label", "Alumni","校友",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "nationalRanking", "National Ranking","全国排名",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "nobelLaureates_label", "Nobel Laureates","诺贝尔奖获得者",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "authority_label", "Authority","管理",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "localAuthority_label", "Local Authority","当地管理部门",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "averageClassSize", "Average Class Size","课平均规模",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "barPassRate", "Bar Pass Rate","Bar通过率",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "campusSize", "Campus Size","校园规模",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "campusType", "Campus Type","校园类型",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "campus_label", "Campus","校园类型",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "classes", "Classes","课",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "language_label", "Language","语言",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "numberOfClassrooms_label", "Number of Classrooms","教室数",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "offeredClasses", "Offered Classes","提供的课程",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "category_label", "Category","类别",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "district_label", "District","区",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "educationSystem_label", "Education System","教育系统",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "type_label", "Type","类型",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "religion_label", "Religion","宗教",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "religiousHead_label", "Religious Head","教头",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyDate(db, sname, "formationDate", "Formation Date","成立日期",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyDateYear(db, sname, "formationYear", "Formation Year","成立年",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyDate(db, sname, "foundingDate", "Founding Date","成立日期",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyDateYear(db, sname, "foundingYear", "Founding Year","成立年",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolPropertyDateYear(db, sname, "closed", "Closed","关闭",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "colour_label", "Color","颜色",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "officialSchoolColour", "Official School Color","校方颜色",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "parentOrganisation_label", "Parent Organization","学生家长组织",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "oversight", "Oversight","监管",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "schoolBoard_label", "School Board","校董事会",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "schoolNumber", "School Number","学校编号",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }

        pv = getSchoolProperty(db, sname, "schoolPatron_label", "School Patron","学校支持者",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "sixthFormStudents", "Sixth Form Students","六年制学生",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "sport", "Sport","体育",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "athletics_label", "Athletics","运动",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "teamName", "Team Name","团队名称",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }
        pv = getSchoolProperty(db, sname, "mascot", "Mascot","福神",isChinese);
        if (pv != null) {
            ret += pv;
            actualHeight++;
        }

        pv = db.getHomePage(sname);
        if (pv != null && !pv.equals("NULL") && pv.length() > 0) {
            if(isChinese)
                ret += "<tr><td>主页</td>" + "<td><a href=\"" + pv + "\">" + pv + "</a></td></tr>";
            else
                ret += "<tr><td>Home Page</td>" + "<td><a href=\"" + pv + "\">" + pv + "</a></td></tr>";
            actualHeight++;
        }

        pv = db.getWikiURL(sname);
        if(isChinese)
            ret += "<tr><td>维基百科页</td>" + "<td><a href=\"" + pv + "\">" + sname + "</a></td></tr>";
        else
            ret += "<tr><td>Wiki Page</td>" + "<td><a href=\"" + pv + "\">" + sname + "</a></td></tr>";
        actualHeight++;

        if(isChinese&&!db.name_cn.get(sname).isEmpty()){
            ret += "<tr><td>互动百科页</td>" + "<td><a href=\"http://www.baike.com/wiki/"+db.name_cn.get(sname)+"\">" + db.name_cn.get(sname) + "</a></td></tr>";
            ret += "<tr><td>百度百科页</td>" + "<td><a href=\"http://baike.baidu.com/item/"+db.name_cn.get(sname)+"\">" + db.name_cn.get(sname) + "</a></td></tr>";
        }
        actualHeight++;
        
        
        pv = db.getRawValue(sname, "depiction");
        if (pv != null && !pv.equals("NULL")) {
            ret += "<tr><td colspan=\"2\" align=\"center\"><img alt=\"\" src=\"" + pv + "\" width=\"" + imageWidth
                    + "\" /></td></tr>\n";
            actualHeight += 10;
        } else {
            pv = db.getRawValue(sname, "thumbnail");
            if (pv != null && !pv.equals("NULL")) {
                ret += "<tr><td colspan=\"2\" align=\"center\"><img alt=\"\" src=\"" + pv + "\" width=\"" + imageWidth
                        + "\" /></td></tr>\n";
                actualHeight += 10;
            }
        }

        ret += "</table></td><td width=\"10%\"></td><td valign=\"top\">\n";
        if (actualHeight >= 20)
            ret += RankingHTML.rightSkyscraper;
        else if (actualHeight >= 10)
            ret += RankingHTML.rightBanner;
        else
            ret += RankingHTML.button120;

        ret += "</td></tr></table>\n<center><br>\n";
        ret += RankingHTML.bottomBanner;
        ret += "</center></body></html>";
        return ret;
    }

    static Date parseDate(String dateString) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:SS+hh:MM");
        try {
            Date date = format.parse(dateString);
            return date;
        } catch (ParseException pe) {
            return null;
        }
    }

    public String getMapScript() {
        String filename = dataDir + File.separator + "MirMap";
        File file = new File(filename);

        Long filelength = file.length();
        byte[] filecontent = new byte[filelength.intValue()];
        try {
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new String(filecontent);
    }

}
